package de.tum.in.eist.im.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.DialogBox;

import de.tum.in.eist.im.client.domain.User;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */

public class EIST_IM implements EntryPoint {
    protected static ChatServiceAsync wtf = GWT.create(ChatService.class);

	@Override
	public void onModuleLoad() {
		
	    VerticalPanel panel = new VerticalPanel();
	    Label usernameLabel = new Label("Username:");
	    Label passwordLabel = new Label("Password:");
	    final PasswordTextBox passwordInput = new PasswordTextBox();
		final TextBox usernameInput = new TextBox();	
		Button loginButton = new Button("Login");
		Button createUserButton = new Button("Register new User");		
	    panel.add(usernameLabel);
		panel.add(usernameInput);
		panel.add(passwordLabel);
		panel.add(passwordInput);
		panel.add(loginButton);
		panel.add(createUserButton);
	    RootPanel.get("center").add(panel);
	    loginButton.addClickHandler(new ClickHandler() {
	        public void onClick(ClickEvent event) {	          
	           String registerName = usernameInput.getText().toString();
	           String registerPwd = passwordInput.getText().toString();
	           wtf.registerNewUser(new User(registerName,registerPwd), null );
	        }
	      });

	}
	

}
